package com.example.util;


import com.example.entity.PointDefend;
import com.example.entity.PointFlow;
import com.example.mapp.PointFlowMapp;
import com.example.service.impl.PointDefendInfoCache;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 	最新积分计算
 */
public class SystemPointUtil {

	/**
	 * 判断多证的情况
	 * @cardType 证件情况
	 * @identification 唯一标识
	 * @infoCache 缓存类
	 */
	public static PointDefend multipleCard(PointDefendInfoCache infoCache, String cardType, String doubleCards, String oneCards,String noneCards) {
		PointDefend defend = new PointDefend();
		if (StringUtil.isNotBlank(cardType)) {
			// 判断多证或者单证
			List<String> cards = Arrays.asList(cardType.split(","));
			if (cards.size() > 1) {
				defend = infoCache.getKeyByValue(doubleCards);
			} else {
				defend = infoCache.getKeyByValue(oneCards);
			}
		} else {
			// 没有证
			defend = infoCache.getKeyByValue(noneCards);
		}

		return defend;
	}

	/**
	 * 插入流水记录表
	 */
	public static void insertFlow(PointFlowMapp pointFlowMapp, int i1, PointDefend pointDefend, int round, String userName, String partyName, String function) {

		if (i1 != 0) {
			// 插入流水信息
			PointFlow flow = new PointFlow();
			flow.setOperationType(pointDefend.getOperationType());
			flow.setOperationContent(pointDefend.getOperationContent());
			flow.setUserName(userName);
			flow.setPartyName(partyName);
			flow.setIdentification(pointDefend.getIdentification());
			flow.setMark(round);
			flow.setFunction(function);
			flow.setCreateBy(userName);
			flow.setCreateDate(DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
			pointFlowMapp.insertPointFlow(flow);

		}
	}

	/**
	 * 获取百分比
	 */


}
